package com.jlboot.core.form;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by 51594 on 2022/7/27.
 */
@Data
public class Form {

    public static Form n() {
        return new Form();
    }

    public final static String ADD="ADD";
    public final static String EDIT="EDIT";
    public final static String DELETE="DELETE";
    public final static String VIEW="VIEW";

    /**
     * 表单类型
     * ADD
     * EDIT
     * DEL
     */
    public String action=VIEW;
    /**
     * 数据
     */
    public Map<String, Object> data = new HashMap<>();




    //////////////////////////////
    public Form setAction(String action){
        this.action=action;
        return this;
    }
    public Form addData(String key,Object value){
        data.put(key,value);
        return this;
    }

    public String toJson() {
        return JSON.toJSONString(this);
    }
}
